package test0ne;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.UUID;

public class StringTest {
    public static void main(String[] args) {
//        int month = 0;
//        int money = 0;
//        double r = 1+0.04/12.0;
//        for(;money<3000000;month++) {
//            money = (int)(money*r + 20000);
//        }
//        System.out.println(month);
//        System.out.println(month/12);

        String dep = "/水滴/基础平台;/水滴/一二三四";
        String[] deps = dep.split(";");

        for (String s : deps) {
            System.out.println(s.length()<5? s:s.substring(4));
        }

        Integer s = 123456;
        System.out.println(String.format("%010d", s));

        LocalDateTime now = LocalDateTime.now();
        System.out.println(now.getDayOfMonth());

        System.out.println(now.minusDays(1));
        System.out.println(now.toString());
//        System.out.println(now.minusDays(1).at());

        LocalDateTime start = now.minusDays(1).withHour(0).withMinute(0).withSecond(0);
        LocalDateTime end = now.minusDays(1).withHour(23).withMinute(59).withSecond(59);
        System.out.println(start  + "  " +end);

        BigDecimal one = new BigDecimal(2*100);
        BigDecimal two = new BigDecimal(1);
        System.out.println(one.divide(two, 2, RoundingMode.HALF_UP));

        System.out.println(start.plusDays(-10).toString());





    }

    public static String proSql(int n) {
        return "ALTER TABLE `shuidi_cs_session`.`session_event_sharding_"+n+"` CHANGE COLUMN `update_time` `update_time` timestamp(6) NOT NULL ON UPDATE CURRENT_TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '更新时间';";
    }

    //生成UUID
    public String proUUID() {
        String uuid = UUID.randomUUID().toString();
        System.out.println(uuid);
        return uuid.replaceAll("-", "");
    }

    public boolean canJumpFromPosition(int pos, int[] a) {
        if(pos == a.length-1) {
            return true;
        }

        int furthestJump = Math.min(a[pos]+pos, a.length-1);

        for (int i = pos+1; i < furthestJump; i++) {
            if(canJumpFromPosition(i,a)) {
                return true;
            }
        }
        return false;
    }

    public boolean canJump(int[] a) {
        int[] dp = new int[a.length];
        //初始化已知解
        dp[a.length-1] = 1;

        for(int i=a.length-2; i>=0;i--) {
            int furthestJump = Math.min(a[i]+i, a.length-1);
            for (int j = i; j < furthestJump - 1; j++) {  //计算
                if(dp[j] == 1) {
                    dp[i] = 1;
                }
            }
        }
        return dp[0] == 1;
    }
}
